﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using DefLib;

namespace GameUI
{
    public class Oco: UIunit
    {
        public static int black = 0;
        public static int white = 1;

        public int co_type;
        private int s_normal = 0;
        private int s_hover = 1;
        private int s_click = 2;
        public Oco()
        {
            
        }
        public Oco CloneCO(float x, float y, int w, int h)
        {
            Oco oco_clone = new Oco();
            List<Sprite> l_sp = new List<Sprite>();
            for (int i_sp = 0; i_sp < l_sprite.Count; i_sp++)
            {
                l_sp.Add(l_sprite[i_sp].Clone(x, y, w, h));
            }

            oco_clone.create(l_sp,
                x > 0 ? x : _x,
                y > 0 ? y : _y,
                w > 0 ? w : _w,
                h > 0 ? h : _h);

            oco_clone.co_type = co_type;

            return oco_clone;
        }
        public void create(int type,float _x, float _y, int _w, int _h)
        {
            List<Sprite> l_sp = new List<Sprite>();

            List<Texture2D> ltt_black = new List<Texture2D>();
            ltt_black.Add(gDef.Content.Load<Texture2D>(@"Resource\black_normal"));
            ltt_black.Add(gDef.Content.Load<Texture2D>(@"Resource\black_hover"));
            ltt_black.Add(gDef.Content.Load<Texture2D>(@"Resource\black_click"));
            Sprite sp_b = new Sprite();
            sp_b.Create(ltt_black, _x, _y, _w, _h);
            l_sp.Add(sp_b);

            List<Texture2D> ltt_white = new List<Texture2D>();
            ltt_white.Add(gDef.Content.Load<Texture2D>(@"Resource\white_normal"));
            ltt_white.Add(gDef.Content.Load<Texture2D>(@"Resource\white_hover"));
            ltt_white.Add(gDef.Content.Load<Texture2D>(@"Resource\white_click"));
            Sprite sp_w = new Sprite();
            sp_w.Create(ltt_white, _x, _y, _w, _h);
            l_sp.Add(sp_w);

            this.create(l_sp, _x, _y,_w,_h);

            co_type = type;

        }
        public override void create(List<Sprite> lS_interface, float _x, float _y,int _w,int _h)
        {
            base.create(lS_interface, _x, _y,_w,_h);
        }
        public override void update(float x, float y, int w, int h)
        {

            this.sp_index.Clear();
            this.sp_state.Clear();
            sp_index.Add(co_type);

            if (is_choise())
            {
                
                sp_state.Add(s_click);
            }
                else
                if (is_hover())
                {
                    sp_state.Add(s_hover);
                }
                else
                {
                    sp_state.Add(s_normal);
                }

            base.update(x,y,w,h);
        }
    }
}
